package edu.polsl.bio.str.manager.messaging;

import edu.polsl.bio.str.manager.command.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessageHandler;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.MessageRejectedException;

/**
 * //todo class description
 * <p/>
 * Created on: Jun 17, 2011 4:50:49 PM <br/>
 * <a href="http://www.polsl.pl">www.polsl.pl</a>
 *
 * @author lukasz.olczak@polsl.pl
 */
public class LoaderCommandsHandler implements MessageHandler {
  /**
   * slf4j Logger.
   */
  private static final Logger log = LoggerFactory.getLogger(LoaderCommandsHandler.class.getName());

  @Override
  public void handleMessage(Message<?> message) throws MessageRejectedException, MessageHandlingException, MessageDeliveryException {
    log.debug("Handling dots results message");
    Command command = (Command) message.getPayload();
    try {
      command.execute();
    } catch (Exception e) {
      log.error("Exception occurred during executing command", e);
    }
  }

}
